<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://www.hx.com/tags" prefix="hx" %>
<%   String path = request.getContextPath();   
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%>
<html>
	<head>
	<title>无标题文档</title>
	<link href="css/style.css" rel="stylesheet" type="text/css">
	<hx:ajax jquery="true"/>
	<script type="text/javascript">
	
	function delMenu(mid){
		$hx.service("mb.haveChildDateAjax",[mid],function(result){
			if(result){
				alert("存在子消息，不允许删除！");
			}else{
				$hx.service("mb.deleteDateAjax",[mid],function(result2){
					if(result2){
						top.document.getElementById("mainFrame").src="<%=basePath%>/messageBoard/getMoredMessageList.action";
					}else{
						alert("删除失败！");
					}
				});
				
			}
		});
	}
	
	function showMessage(id){
		if(document.getElementById(id).style.display){
			document.getElementById(id).style.display="";
		}else{
			document.getElementById(id).style.display="none";
		}
	}
	
	function toSendMessage(frmid){
		var murl = "<%=basePath%>/messageBoard/saveMessage.action";
		var parmers = $("#"+frmid).serialize();
		$.post(murl,parmers,function(boo){
			if(boo){
				top.document.getElementById("mainFrame").src="<%=basePath%>/messageBoard/getMoredMessageList.action";
			}else{
				alert("回复失败！");
			}
			
		});
	}
	</script>
	<style type="text/css">
		body{
			background-color: white;
		}
		a:HOVER {
				color: red;
			}
	</style>
	</head>
	<body>
		<div style="font-size: 12px;line-height:25px;color: red ">当前位置：留言板消息管理</div>
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			class="thetable" style="font-size: 13px;margin-top: 10px;">
			<thead>
				<tr>
					<td colspan="7" style="width: 100%"><hr/></td>
				</tr>
				<tr height="30px;" style="font-weight: bold;">
					<td width="15%" align="center" valign="middle">序号</td>
					<td width="15%" align="center" valign="middle">留言时间</td>
					<td width="15%" align="center" valign="middle">用户名</td>
					<td width="10%" align="center" valign="middle">留言内容</td>
					<td width="15%" align="center" valign="middle">类型</td>
					<td width="20%" align="center" valign="middle">操作</td>
				</tr>
			</thead>
			<s:iterator value="messageMap" id="column" status="status">
				<tr onMouseOut="this.style.background='#eeeeee'"
					onMouseOver="this.style.background='#F4E088'" bgcolor="#eeeeee">
				<td height="29" align="center" valign="middle">
					<s:property value="#status.index+1" />
				</td>
				<td height="29" align="center" valign="middle">
					<s:date name="#column.key.MDate" format="yyyy-MM-dd hh:mm:ss" />
				</td>
				<td align="center" valign="middle">
					<s:property value="#column.key.MUsername"/>
				</td>
				<td align="center" valign="middle">
					<s:property value="#column.key.MContent"/>
				</td>
				<td align="center" valign="middle">
					留言
				</td>
				
				<td align="center" valign="middle">
					<a href="javascript:void(0)" onClick="showMessage('${key.id}_id')">回复</a>
					<a href="javascript:void(0)" onClick="delMenu('${key.id}')">删除</a>
				</td>
				</tr>
				<div>
				<tr id="${key.id}_id" style="display: none">
					<form action="" method="post" name="${key.id}_frm" id="${key.id}_frm">
					<td colspan="4" width="100%"> 
							<input type="hidden" name="messageBoard.fkMId" value="${key.id }">
							<input type="hidden" name="messageBoard.MUsername" value="${user.userName}">
							<input type="hidden" name="messageBoard.MOpenid" value="${user.id}">
							<input type="text" name="messageBoard.MContent" value="" style="width: 100%"/>
							
					</td>
					<td align="left">
						<input type="button" name="sumbmit" value="回复" onclick="toSendMessage('${key.id}_frm')"/>
					</td>
					</form>
				</tr>
				
					<s:iterator value="#column.value" status="s" id="mes">
							<tr onMouseOut="this.style.background='#ffffff'"
									onMouseOver="this.style.background='#F4E088'" bgcolor="#ffffff">
									<td height="29" align="right" valign="middle">
										回复<s:property value="#s.index+1" />
									</td>
									<td height="29" align="left" valign="middle">
										<font style="margin-left: 20px;">&nbsp;&nbsp;<s:date name="MDate" format="yyyy-MM-dd hh:mm:ss" /></font>
									</td>
									<td align="center" valign="middle">
										<s:property value="MUsername"/>
									</td>
									<td align="center" valign="middle">
										<s:property value="MContent"/>
									</td>
									<td align="center" valign="middle">
										回复
									</td>
									<td align="center" valign="middle">
											<a href="javascript:void(0)" onClick="delMenu('${id}')">删除</a>
									</td>
								</tr>
					</s:iterator>
			</s:iterator>
			<tr align="center" style="background-color: #cccccc;height: 30px;line-height: 30px;font-size: 14px;font-weight: bold;cursor: pointer;">
				<td colspan="2">当前第${pageData.startPage}页      共${pageData.totlePage}页</td>
				<td><a href="<%=basePath %>/messageBoard/getMoredMessageList.action?currentPage=${pageData.currentPage-1}">上一页</a>   <a href="<%=basePath %>/messageBoard/getMoredMessageList.action?currentPage=${pageData.currentPage+1}">下一页</a></td>
				<td></td>
				<td colspan="2">当前第${pageData.startNum}-${pageData.endNum}条    共${pageData.totle}条</td>
			</tr>
		</table>
	</body>
</html>

